#include <modules\graphics\entity.h>

namespace DelGE
{
	namespace Modules
	{
		namespace Graphics
		{
			Entity::Entity()
			{
				this->bHidden = false;
				this->vModels = vector<Model*>();
			}

			Entity::~Entity()
			{
				this->bHidden = false;
				this->vModels.clear();
			}

			void Entity::DestroyModels()
			{
				if (!this->vModels.empty())
				{
					for (unsigned int iModelIndex = 0; iModelIndex < this->vModels.size(); iModelIndex ++)
					{
						delete this->vModels[iModelIndex];
					}

					this->vModels.clear();
				}
			}

			void Entity::Hide()
			{
				this->bHidden = true;
			}

			void Entity::Show()
			{
				this->bHidden = false;
			}
			
			bool Entity::IsHidden()
			{
				return this->bHidden;
			}

			void Entity::AddModel(Model* pModel)
			{
				Entity::vModels.push_back(pModel);
			}

			Model* Entity::GetModel(int iIndex)
			{
				if (iIndex < 0 || iIndex >= this->GetModelCount()) return NULL;

				return this->vModels[iIndex];
			}

			int Entity::GetModelCount()
			{
				return this->vModels.size();
			}

			void Entity::Destroy()
			{
				this->DestroyModels();
			}
		}
	}
}